import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../config/database';
import Circle from './Circle';
import InterestTag from './InterestTag';

class CircleTag extends Model {
    public id!: string;
    public circleId!: string;
    public tagId!: string;
    public readonly createdAt!: Date;
    public readonly updatedAt!: Date;
}

CircleTag.init(
    {
        id: {
            type: DataTypes.UUID,
            defaultValue: DataTypes.UUIDV4,
            primaryKey: true,
        },
        circleId: {
            type: DataTypes.UUID,
            allowNull: false,
            references: {
                model: Circle,
                key: 'id',
            },
        },
        tagId: {
            type: DataTypes.UUID,
            allowNull: false,
            references: {
                model: InterestTag,
                key: 'id',
            },
        },
    },
    {
        sequelize,
        tableName: 'circle_tags',
        timestamps: true,
        indexes: [
            {
                unique: true,
                fields: ['circleId', 'tagId'],
            },
        ],
    }
);

export default CircleTag; 